#include "Player.h"
#include "IntroState.h"
namespace Advanced2D
{
	Player::Player(void):Object()
	{
		sprPlayer=new Sprite();
		sprPlayer->loadImage("Bullet.png");
		sprPlayer->setCurrentFrame(0);
		sprPlayer->setWidth(25);
		sprPlayer->setHeight(20);
		sprPlayer->setColumns(4);
		sprPlayer->setTotalFrames(4);
		sprPlayer->setFrameTimer(60);
		this->isMoving=false;
		this->setObjectType(10);
	}


	Player::~Player(void)
	{

	}
	void Player::setPostion(D3DXVECTOR3 pos)
	{
		this->position=pos;
		this->sprPlayer->setPosition(pos);

	}
	void Player::setCurrentFrame(int frame)
	{
		this->currentFrame=frame;
		this->sprPlayer->setCurrentFrame(frame);
	}
	void Player::draw(RECT screenRect)
	{
		sprPlayer->draw(screenRect);

	}
	void Player::draw()
	{
		sprPlayer->draw();
	}
	void Player::move()
	{
		//QuadTree* tree=CIntroState::map->getQuadtree();
		//vector<Object*>* objList=new vector<Object*>();
		//tree->CheckCollision(tree->_pRoot,this->objRect,*objList);
		//this->oldPos=this->position;
		//sprPlayer->move();
		oldPos.x=sprPlayer->getPosition().getX();
		oldPos.y=sprPlayer->getPosition().getY();
		oldPos.z=0;
		sprPlayer->move();
		
		D3DXVECTOR3 temp;
		temp.x=sprPlayer->getPosition().getX();
		temp.y=sprPlayer->getPosition().getY();
		temp.z=sprPlayer->getPosition().getZ();
		this->setPostion(temp);

		this->objRect.left += (position.x-oldPos.x);
		this->objRect.top += (position.y-oldPos.y);
		this->objRect.right = (this->objRect.left)+ sprPlayer->getWidth();
		this->objRect.bottom = this->objRect.top + sprPlayer->getHeight();
		this->setIsMoving(true);

	}
	void Player::animate()
	{
		sprPlayer->animate();

	}


}
